﻿Imports BUS
Imports DTO
Public Class frmBaoCaoThongKeSachTraTre : Inherits DevComponents.DotNetBar.Office2007Form
    Private m_nhanvien As CNhanVienDTO
    Public Property NhanVien() As CNhanVienDTO
        Get
            Return m_nhanvien
        End Get
        Set(ByVal value As CNhanVienDTO)
            m_nhanvien = value
        End Set
    End Property
    Public Function ConvertFromListToDataSet(ByVal lphieutratre As List(Of CChiTietPhieuMuonDTO)) As DataTable
        Dim tb As New DataTable()
        tb.Columns.Add("TenSach")
        tb.Columns.Add("NgayMuon")
        tb.Columns.Add("SoNgayTraTre")
        Dim newrow As DataRow
        For Each item As CChiTietPhieuMuonDTO In lphieutratre
            newrow = tb.NewRow()
            newrow("TenSach") = New CSachBUS().LayTenSach(item.MaSach)
            newrow("NgayMuon") = item.NgayMuon
            newrow("SoNgayTraTre") = item.SoNgayMuon
            tb.Rows.Add(newrow)
        Next
        Return tb
    End Function

    Private Sub frmBaoCaoThongKeSachTraTre_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim view As New rptBaoCaoThongKeSachTraTre()
        view.SetDataSource(ConvertFromListToDataSet(New CChiTiepPhieuMuonBUS().ThongKeSachTraTre()))
        view.SetParameterValue("NguoiLap", m_nhanvien.HoTen)
        CrystalReportViewer1.ReportSource = view
        CrystalReportViewer1.Refresh()
    End Sub
End Class